package com.cddx.logistics.util.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class R {

    private static final Integer CODE_SUCCESS = 0;
        private static final Integer CODE_ERROR = 1;
    private Integer code;
    private String msg;//错误的详情信息
    private Object data;//数据


    public static R ok() {
        return new R(CODE_SUCCESS, "请求成功", null);
    }

    public static R ok(Object data) {
        return new R(CODE_SUCCESS, "请求成功", data);
    }

    public static R error(String msg) {
        return new R(CODE_ERROR, msg, null);
    }

    public static R error(Integer code, String msg) {
        return new R(code, msg, null);
    }

    public static R error() {
        return new R(CODE_ERROR, "系统错误", null);
    }
}

